<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/wsDangan.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/bootstrap.css">

    <!-- 引入组件库 -->
    <script src="${request.contextPath}/statics/vue/vue.js"></script>
    <script src="${request.contextPath}/statics/vue/index.js"></script>
    <script src="${request.contextPath}/statics/vue/axios.js"></script>
    <link rel="stylesheet" href="${request.contextPath}/statics/vue/index.css">
    <script src="${request.contextPath}/statics/js/bootstrap.js"></script>
    <script src="${request.contextPath}/statics/js/jquery1.9.1.js"></script>
    <script src="${request.contextPath}/statics/js/config.js"></script>
    <script type="text/javascript" src="${request.contextPath}/statics/js/jqprint/jquery.jqprint-0.3.js"></script>
    <script type="text/javascript" src="${request.contextPath}/statics/js/jqprint/jquery-migrate.js"></script>
    <script type="text/javascript" src="${request.contextPath}/statics/js/table2Excel/jquery.base64.js"></script>
    <script type="text/javascript" src="${request.contextPath}/statics/js/table2Excel/tableExport.js"></script>
    <script src="${request.contextPath}/statics/js/url-search-params.js"></script>

    <title>业务档案管理</title>
</head>
<body class="body" style="background-color:#F1F1F1;">
<div id="app" class="container app" v-cloak style="width: 100%;height: 100%;padding: 0px;">

    <#include "danganHeader.html">
    <el-row class="search-container" style="padding: 0px">
        <div style="width: 15%;display: block;height: 777px;float: left;background-color: #f7f8fa;">
            <el-menu :default-openeds="['1', '3']"
                     default-active="1-1">
                <el-submenu index="1">
                    <template slot="title"><i class="el-icon-message"></i>文书档案</template>
                    <el-menu-item-group>
                        <el-menu-item @click="wsGd=true,wsEdit=false" index="1-1">文书归档</el-menu-item>
                        <el-menu-item @click="wsGd=false,wsEdit=true" index="1-2">档案整理</el-menu-item>
                    </el-menu-item-group>
                </el-submenu>
                <el-submenu index="2">
                    <template slot="title"><i class="el-icon-s-cooperation"></i>业务档案</template>
                    <el-menu-item-group>
                        <el-menu-item index="2-1">档案整理</el-menu-item>
                    </el-menu-item-group>
                </el-submenu>
            </el-menu>
        </div>
        <!--文书归档-->
        <div v-show="wsGd"
             style="margin-left: 15%;width: 85%;height: 777px;background-color:#F1F1F1;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
            <el-row>
                <el-col :span="14"
                        style="margin-left: 16%;margin-top:20px;background: #ffffff;min-height: 400px;padding:20px 55px 0px 55px ;">

                    <el-form ref="form" :model="gdForm" label-width="120px">
                        <el-form-item label="收文号：">
                            <el-input v-model="gdForm.swh" style="width:360px"></el-input>
                            <el-button type="primary" @click="searchOaWs" style="margin-left: 10px;">搜索</el-button>
                        </el-form-item>
                        <el-form-item label="影像文件：">

                            <el-input v-model="upload.filePath" style="width:360px;float: left;"></el-input>
                            <el-button v-show="gdForm.upLoadType==1"
                                       style="float: left;margin-left: 13px;"
                                       type="primary" @click="loadPdf(0,3)">查看
                            </el-button>
                            <el-upload
                                    v-show="gdForm.upLoadType==2"
                                    class="upload-demo"
                                    :action="upload.url"
                                    multiple=false
                                    show-file-list=false
                                    :data="upload.params"
                                    :on-success="uploadSuccess"
                                    style="float: left;">
                                <el-button style="margin-left: 13px;" type="primary">上传</el-button>
                            </el-upload>
                            <el-radio-group style="margin-left: 20px;" v-model="gdForm.upLoadType">
                                <el-radio :label="1">ftp</el-radio>
                                <el-radio :label="2">本地</el-radio>
                            </el-radio-group>
                        </el-form-item>

                        <el-row :gutter="20">
                            <el-col :span="12">
                                <el-form-item label="文件权限：">
                                    <el-select v-model="gdForm.jnmlqx" placeholder="请选择文件权限">
                                        <el-option label="外部一般" value="1">外部一般</el-option>
                                        <el-option label="内部一般" value="2">内部一般</el-option>
                                        <el-option label="内部机密" value="3">内部机密</el-option>
                                        <el-option label="外部机密" value="4">外部机密</el-option>
                                        <el-option label="绝密" value="5">绝密</el-option>
                                    </el-select>

                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="案卷权限：">
                                    <el-select v-model="gdForm.inmlqx" placeholder="请选择文件权限">
                                        <el-option label="外部一般" value="1">外部一般</el-option>
                                        <el-option label="内部一般" value="2">内部一般</el-option>
                                        <el-option label="内部机密" value="3">内部机密</el-option>
                                        <el-option label="外部机密" value="4">外部机密</el-option>
                                        <el-option label="绝密" value="5">绝密</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-row :gutter="20">
                            <el-col :span="12">
                                <el-form-item label="分类号：">
                                    <el-input disabled="true" v-model="gdForm.flh"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="全宗号：">
                                    <el-input v-model="gdForm.qzh"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="20">
                            <el-col :span="12">
                                <el-form-item label="件号：">
                                    <el-input v-model="gdForm.js"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="页数：">
                                    <el-input v-model="gdForm.ys"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="20">
                            <el-col :span="12">
                                <el-form-item label="*年度：">
                                    <el-input @change="getJs" type="number" v-model="gdForm.nd"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="保管期限：">
                                    <el-select @change="getJs" v-model="gdForm.bgqx" placeholder="">
                                        <el-option label="10年" value="10年">10年</el-option>
                                        <el-option label="30年" value="30年">30年</el-option>
                                        <el-option label="长期" value="长期">长期</el-option>
                                        <el-option label="短期" value="短期">短期</el-option>
                                        <el-option label="永久" value="永久">永久</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="20">
                            <el-col :span="12">
                                <el-form-item label="责任人：">
                                    <el-input v-model="gdForm.zrr"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="*文号：">
                                    <el-input v-model="gdForm.wh"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-form-item label="*文件标题：">
                            <el-input type="textarea" v-model="gdForm.bt"></el-input>
                        </el-form-item>
                        <el-row :gutter="20">
                            <el-col :span="12">
                                <el-form-item label="日期：">
                                    <el-date-picker
                                            v-model="gdForm.rq"
                                            type="date"
                                            value-format="yyyy-MM-dd"
                                            placeholder="选择日期">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="状态：">
                                    <el-tag :type="gdForm.wsDanganStatus">{{gdForm.isGD?'已归档':'未归档'}}</el-tag>
                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-form-item>
                            <el-button type="primary" @click="guiDang">归档</el-button>
                        </el-form-item>
                    </el-form>

                </el-col>
            </el-row>
        </div>
        <!--文书编辑，导出excel-->
        <div v-show="wsEdit"
             style="margin-left: 15%;width: 85%;height: 777px;padding:10px 30px 30px 30px ;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
            <el-form ref="form" :inline="true" size="small" :model="form" label-width="40px">
                <el-form-item label="件号">
                    <el-input v-model="form.js" type="number"></el-input>
                </el-form-item>
                <el-form-item label="保管期限" label-width="60px;">
                    <el-select v-model="form.bgqx" style="width: 100px;" placeholder="不限">
                        <el-option label="不限" value=""></el-option>
                        <el-option v-for="bgqx in bgqxOptions" :label="bgqx.code" :value="bgqx.value"></el-option>

                    </el-select>
                </el-form-item>
                <el-form-item label="年度">
                    <el-select v-model="form.nd" style="width: 100px;" placeholder="不限">
                        <el-option label="不限" value=""></el-option>
                        <el-option v-for="year in years" :label="year" :value="year"></el-option>

                    </el-select>
                </el-form-item>
                <el-form-item label="文号">
                    <el-input v-model="form.wh"></el-input>
                </el-form-item>
                <el-form-item label="文件标题" label-width="60px;">
                    <el-input v-model="form.bt" style="width: 250px;"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="search">查询</el-button>
                </el-form-item>
            </el-form>
            <div style="height: 40px;display: block;padding-bottom: 15px;">
                <el-row>
                    <el-col :span="16">
                        <el-pagination
                                style="margin-bottom: 10px;"
                                background
                                :page-sizes="[10,200, 500, 1000]"
                                :page-size="10"
                                layout="prev, pager, next,total,sizes"
                                @current-change="danganPageChange"
                                @size-change="danganPageSizeChange"
                                @prev-click="danganPageChange"
                                @next-click="danganPageChange"
                                :current-page="page.currPage"
                                :total="page.totalCount">
                        </el-pagination>
                    </el-col>
                    <el-col :span="8">
                        <el-button type="primary" @click="exportExcel" size="mini">导出excel</el-button>
                        <el-button type="primary" @click="printTable" size="mini">打印</el-button>
                    </el-col>
                </el-row>


            </div>
            <el-row>
                <el-table
                        :data="tableData"
                        stripe
                        border
                        size="mini"
                        max-height="640"
                        @selection-change="handleSelectionChange"
                        style="width: 100%;height: 640px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)"
                        id="wsTable"
                >
                    <el-table-column
                            label="打印"
                            type="selection"
                            width="55">
                    </el-table-column>
                    <el-table-column
                            prop="xh"
                            label="序号"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="bt"
                            label="文件标题"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="bgqx"
                            label="保管期限">
                    </el-table-column>
                    <el-table-column
                            prop="wh"
                            label="文号">
                    </el-table-column>
                    <el-table-column
                            prop="nd"
                            label="年度">
                    </el-table-column>
                    <el-table-column
                            prop="js"
                            label="件号">
                    </el-table-column>
                    <el-table-column
                            label="操作">
                        <template slot-scope="scope">
                            <el-button @click="editWsDangan(scope.row)" type="primary" size="small">编辑</el-button>
                            <el-button @click="deleteWsFile(scope.row,scope.$index)" type="danger" size="small">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-row>
        </div>
    </el-row>
    <table id="exportTable" class="table table-striped table-bordered" hidden="hidden" >
        <thead>
            <tr>
                <th class="col-xs-1" style="width:5%"> 序号</th>
                <th class="col-xs-2" style="width:10%">档号</th>
                <th class="col-xs-2"style="width:15%">文号</th>
                <th class="col-xs-2" style="width:8%">责任人</th>
                <th class="col-xs-3" style="width:32%">题名</th>
                <th class="col-xs-1" style="width:15%"> 日期</th>
                <th class="col-xs-1" style="width:5%">密级</th>
                <th class="col-xs-1" style="width:5%">页数</th>
                <th class="col-xs-1" style="width:5%">备注</th>
            </tr>
        </thead>
        <tbody>
            <tr v-for=" ws in multipleSelection" >
                <td>{{ws.js}}</td>
                <td>{{ws.nd+"-"+ws.js}}</td>
                <td>{{ws.wh}}</td>
                <td>市国土局</td>
                <td>{{ws.bt}}</td>
                <td>{{ws.rq}}</td>
                <td>秘密</td>
                <td>{{ws.ys}}</td>
                <td></td>
            </tr>
        </tbody>
    </table>
    <el-dialog :visible.sync="pdfDialogVisible"
               modal-append-to-body="false"
               fullscreen=true
               center
               modal=false
    >
        <div style="height: 741px;">
            <iframe contextmenu="return false;" scrolling="yes" style="width:100%;height:100%;"
                    :src="pdfUrl">
            </iframe>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="pdfDialogVisible=false">返  回</el-button>
          </span>
    </el-dialog>
    <el-dialog :visible.sync="editWsDialogVisible"
               modal-append-to-body="false"
               fullscreen=true
               center
               modal=false
               top="142px">
        <el-row style="height:740px;">
            <el-col :span="15" style="height: 100%;">
                <div style="height: 100%;width: 100%;float: left">
                    <iframe id="editPdfIframe" contextmenu="return false;" scrolling="yes" style="width:97%;height:100%;"
                            :src="pdfUrl">
                    </iframe>
                </div>
            </el-col>
            <el-col :span="8" style="height:100%">
                <div class="row modle_nomh " style="padding-left: 20px;background: #DEDEDE">
                    <h5>文件信息</h5>
                </div>
                <div class="row modle_nomh  " style="margin-top: 10px;padding: 15px 30px 0px 0px;">
                    <el-form ref="form" :model="dangan" size="small" label-width="120px">
                        <el-form-item label="分类号：">
                            <el-input v-model="dangan.flh" style="width:360px"></el-input>
                        </el-form-item>
                        <el-form-item label="件号：">
                            <el-input v-model="dangan.js" style="width:360px"></el-input>
                        </el-form-item>
                        <el-form-item label="年度：">
                            <el-input type="number" v-model="dangan.nd" style="width:360px"></el-input>
                        </el-form-item>
                        <el-form-item label="责任人：">
                            <el-input v-model="dangan.zrr" style="width:360px"></el-input>
                        </el-form-item>
                        <el-form-item label="保管期限：">
                            <el-select v-model="dangan.bgqx" placeholder="">
                                <el-option label="10年" value="10年">10年</el-option>
                                <el-option label="30年" value="30年">30年</el-option>
                                <el-option label="长期" value="长期">长期</el-option>
                                <el-option label="短期" value="短期">短期</el-option>
                                <el-option label="永久" value="永久">永久</el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="文号：">
                            <el-input v-model="dangan.wh" style="width:360px"></el-input>
                        </el-form-item>
                        <el-form-item label="文件标题：">
                            <el-input type="textarea" v-model="dangan.bt"></el-input>
                        </el-form-item>
                        <el-form-item label="日期：">
                            <el-date-picker
                                    v-model="dangan.rq"
                                    type="date"
                                    placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item label="全宗号：">
                            <el-input v-model="dangan.qzh"></el-input>
                        </el-form-item>
                        <el-form-item label="案卷权限：">
                            <el-select v-model="dangan.mlqx" placeholder="请选择文件权限">
                                <el-option label="外部一般" value="1">外部一般</el-option>
                                <el-option label="内部一般" value="2">内部一般</el-option>
                                <el-option label="内部机密" value="3">内部机密</el-option>
                                <el-option label="外部机密" value="4">外部机密</el-option>
                                <el-option label="绝密" value="5">绝密</el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="上传路径：">
                            <el-input v-model="dangan.filePath" style="width:360px;float: left;"></el-input>
                            <el-upload
                                    class="upload-demo"
                                    :action="upload.url"
                                    multiple=false
                                    show-file-list=false
                                    :data="upload.params"
                                    :on-success="uploadSuccess"
                                    style="float: left;">
                                <el-button style="margin-left: 13px;" type="primary">上传</el-button>
                            </el-upload>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="saveWsDangan">保存</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </el-col>
            <el-col :span="1"></el-col>
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="editWsDialogVisible = false">返  回</el-button>
          </span>
    </el-dialog>
</div>


</body>
<style type="text/css">
    .modle_nomh {
        background-color: #ffffff;
        border: solid 1px #ccc;
        border-radius: 5px;
    }
</style>
<script type="text/javascript">
    const make_cols = refstr => Array(XLSX.utils.decode_range(refstr).e.c + 1).fill(0).map((x,i) => ({name:XLSX.utils.encode_col(i), key:i}));

    const _SheetJSFT = [
        "xlsx", "xlsb", "xlsm", "xls", "xml", "csv", "txt", "ods", "fods", "uos", "sylk", "dif", "dbf", "prn", "qpw", "123", "wb*", "wq*", "html", "htm"
    ].map(function(x) { return "." + x; }).join(",");
    const http = axios.create({

        baseURL: getUrl(),
        timeout: 100000,
        withCredentials: false, // 是否允许带cookie这些
        // headers: {'Content-Type': 'application/json'}
    });
    var vm = new Vue({
        el: '#app',
        data: {
            gdForm: {
                js: 1,//件号
                ys: 1,
                bgqx: "10年",//保管期限
                nd: '2019',//年度
                wh: "",//文号
                swh: "",//收文号
                bt: "",//文件标题
                flh: "A",
                wh: "",//文号
                bt: "",//标题
                rq: "",//文档日期
                zrr: "",//责任人
                qzh: "113",//全宗号
                jnmlqx: "1",//文件权限
                inmlqx: "1",//案卷权限
                wsDanganStatus: "danger未归档",//文书档案状态，danger未归档，success已经归档
                upLoadType: 1,//1是ftp，2是本地上传
                serverXh: 0,//Oa服务器的序号
                isGD: false,
                vrecid: 0,//oa服务器文书档案的主键
            },
            form: {
                js: "",//件号
                bgqx: "",//保管期限
                nd: "",//年度
                wh: "",//文号
                bt: "",//文件标题
                flh: "A",
            },
            pdfDialogVisible: false,//查看pdf
            editWsDialogVisible: false,//文书档案编辑
            tableData: [],
            page: {
                totalCount: 0,
                pageSize: 10,
                totalPage: 1,
                currPage: 1,
            },
            bgqxOptions: [],//保管期限选择项
            dangan: {
                filePath: "",//档案的文件全路径
                jnmlbh: 0,
            },//显示pdf对应的文书档案的详细属性
            years: [],
            szd: [],//所在地
            showPdfNbxh: '',
            multipleSelection: [],
            wsGd: true,
            wsEdit: false,
            upload: {
                // 地址
                url: getUrl()+'/file/upload',
                // token
                cookies: true,
                // 上传参数
                params: {},
                uuid: "",//文件上传返回的uuid
                filePath: '',
                reUpLoadJnml: false,
            },
            daJnmlData: [],//文书档案卷内目录
            pdfUrl: "",//pdf的路径



            loginForm:{
                loginVisible:false,//登录窗口显示
                username:"",
                password:"",
                dialog:false,
                rules:{
                    username:[{required: true,message:'请输入登录名', trigger: 'blur'}],
                    password: [{required: true,message:'请输入密码', trigger: 'blur'}]
                }
            },
            pwdForm:{
                resetPasswordVisible:false,
                oldPassword:'',
                newPassword:'',
                rules:{
                    oldPassword:[{required: true,message:'请输入原密码，初始密码123456', trigger: 'blur'}],
                    newPassword: [{required: true,message:'请输入新密码', trigger: 'blur'}]
                },
                showCancel:true,
            },
            SheetJSFT: _SheetJSFT,
            exportExcelData:[],
            username:''
        },
        mounted() {
            // this.isLogin()
            this.username=window.localStorage.getItem("username")
            let date = new Date()
            this.loadDangan(1);
            this.loadBgqx();
            this.initYear();
            this.gdForm.nd = date.getFullYear()
            this.getJs()

        },
        methods: {
            printTable(){
                if(this.multipleSelection.length>0){
                    $("#exportTable").prop("hidden", false);
                    $("#exportTable").jqprint();
                    $("#exportTable").prop("hidden", true);
                }else{
                    this.$message.info("您没有选中任何数据")
                }

            },
            exportExcel(){
                if(this.multipleSelection.length>0){
                    $("#exportTable").prop("hidden", false);
                    $("#exportTable").tableExport({type: 'excel', escape: 'false'});
                    $("#exportTable").prop("hidden", true);
                }else{
                    this.$message.info("您没有选中任何数据")
                }
            },
            loadHtml(url,flh){
                parent.location.href=url
                this.form.flh=flh
            },
            guiDang() {
                if (this.gdForm.isGD) {
                    this.$message.warning("该文档已经归档，请不要重复归档")
                    return;
                }
                let params = new URLSearchParams();
                params.append("js", this.gdForm.js)
                params.append("bt", this.gdForm.bt)
                params.append("bgqx", this.gdForm.bgqx)
                params.append("nd", this.gdForm.nd)
                params.append("wh", this.gdForm.wh)
                params.append("qzh", this.gdForm.qzh)
                params.append("flh", this.gdForm.flh)
                params.append("pflh", this.gdForm.flh)
                params.append("ys", this.gdForm.ys)
                params.append("zrr", this.gdForm.zrr)
                params.append("rq", this.gdForm.rq)
                params.append("filePath",  this.upload.filePath)
                params.append("type", this.gdForm.upLoadType)
                params.append("mlqx", this.gdForm.jnmlqx)
                params.append("serverXh", this.gdForm.serverXh)
                params.append("vrecid", this.gdForm.vrecid)
                http.post('/daws/guiDang', params).then(function (resp) {
                    console.info(resp)
                    if (resp.data.code == 0) {
                        this.getJs()
                        this.$message({
                            message: '归档成功',
                            type: 'success',
                            offset: 100
                        });
                        this.gdForm.bt=""
                        this.gdForm.wh=""
                        this.gdForm.swh=""
                    } else {
                        this.$message({
                            message: '归档失败:' + resp.data.msg,
                            type: 'error',
                            offset: 100
                        });
                    }
                }.bind(this)).catch(function (err) {
                    console.error(err)
                });
            },
            search() {
                this.page.page = 1
                this.loadDangan()
            },
            searchOaWs() {
                let params = new URLSearchParams();

                params.append("swbh", this.gdForm.swh)
                params.append("bt", this.gdForm.bt)
                params.append("nd", this.gdForm.nd)
                params.append("wh", this.gdForm.wh)
                http.post('/daOaWs/list', params).then(function (resp) {
                    console.log("搜索oa文书档案结果")
                    console.log(resp)
                    if (resp.data.code == 0) {
                        let oaWs
                        if (resp.data.page.totalCount > 0) {
                            oaWs = resp.data.page.list[0]
                            this.$message.success("搜索成功")
                            this.gdForm.swh = oaWs.vswbh
                            this.gdForm.wh = oaWs.vlwbh
                            this.gdForm.rq = oaWs.vlastdate
                            this.gdForm.nd = oaWs.nd
                            this.gdForm.filePath = oaWs.lj
                            this.upload.filePath=oaWs.lj
                            this.gdForm.bgqx = oaWs.bgqx
                            this.gdForm.bt = oaWs.vlwbt
                            this.gdForm.serverXh = oaWs.serverxh
                            this.gdForm.vrecid = oaWs.vrecid
                            this.gdForm.zrr=oaWs.vlwdw
                            this.isGuiDang(oaWs.vrecid)
                        } else {
                            this.$message.info("没有搜索到对应的数据")
                        }

                    }
                }.bind(this)).catch(function (err) {
                    console.error(err)
                });
            },
            loadDangan() {
                let params = new URLSearchParams();

                params.append("js", this.form.js)
                params.append("bt", this.form.bt)
                params.append("bgqx", this.form.bgqx)
                params.append("nd", this.form.nd)
                params.append("wh", this.form.wh)
                params.append("flh", this.form.flh)
                params.append("jnmlqx", this.page.jnmlqx)
                params.append("page", this.page.currPage)
                params.append("limit",this.page.pageSize)
                http.post('/daws/list', params).then(function (resp) {
                    this.tableData = resp.data.page.list

                    this.page.totalCount = resp.data.page.totalCount
                    this.page.pageSize = resp.data.page.pageSize
                    this.page.totalPage = resp.data.page.totalPage
                    this.page.currPage = resp.data.page.currPage
                    for (let i = 0; i < this.tableData.length; i++) {
                        this.tableData[i].xh = this.page.pageSize * (this.page.currPage - 1) + i + 1;
                    }
                }.bind(this)).catch(function (err) {
                    console.error(err)
                });
            },
            loadPdf(jnmlbh, type) {
                if (type == 1) {//根据uuid返回刚上传的文件
                    this.pdfUrl = getUrl()+"/statics/pdf/web/viewer.html?file=/dangan/file/" + this.upload.uuid;
                    this.pdfDialogVisible = true
                } else if (type == 2) {//根据卷目录编号获取文件
                    this.pdfUrl = getUrl()+"/statics/pdf/web/viewer.html?file=/dangan/file/download/" + jnmlbh;
                    document.getElementById('editPdfIframe').contentWindow.location.reload(true);
                } else if (type == 3) {
                    this.pdfUrl = getUrl()+"/statics/pdf/web/viewer.html?file=/dangan/file/getOaWsFile/"
                        + this.gdForm.vrecid
                    this.pdfDialogVisible = true
                }
            },
            danganPageChange(page) {//翻页
                this.page.currPage = page
                this.loadDangan()
            },
            danganPageSizeChange(pageSize) {//翻页
                this.page.pageSize = pageSize
                this.loadDangan()
            },
            /**
             * 加载所在地
             */
            loadSzd() {
                http.post('/sys/dict/list', {name: '所在地'}).then(function (resp) {

                }).bind(this).catch(function (err) {
                    console.error(err)
                })
            },
            loadBgqx() {
                let params = new URLSearchParams;
                // params.append("name","保管期限")
                http.post('/sys/dict/list?type=' + "保管期限").then(function (resp) {
                    // this.bgqxOptions=resp.data.page.list
                    this.bgqxOptions = resp.data.page.list
                }.bind(this)).catch(function (err) {
                    console.error(err)
                })
            },
            initYear() {
                var year = new Date().getFullYear();
                this.years[0] = year
                for (var i = 1; i < 30; i++) {
                    this.years[i] = year - i;
                }
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            editWsDangan(row) {
                this.editWsDialogVisible = true
                this.upload.reUpLoadJnml = false
                this.dangan = row
                this.loadJnml(row.nbxh)
            },
            uploadSuccess: function (response, file, fileList) {
                console.info(response)
                if (response.code == 0) {
                    this.upload.filePath = response.filePath
                    this.upload.uuid = response.uuid
                    this.dangan.filePath = response.filePath
                    if (this.wsEdit) {
                        this.upload.reUpLoadJnml = true
                    }
                }
            },
            getJs() {
                let params = new URLSearchParams();
                params.append("bgqx", this.gdForm.bgqx)
                params.append("nd", this.gdForm.nd)
                http.post("/daws/getJs", params).then(function (resp) {
                    this.gdForm.js = resp.data.js
                }.bind(this)).catch(function (err) {
                    console.error(err)
                })
            },
            /**
             * 判断文件是否归档
             */
            isGuiDang(vrecid) {
                let params = new URLSearchParams();

                params.append("vrecid", vrecid)
                params.append("flh", "A")
                http.post('/daws/list', params).then(function (resp) {
                    console.log("是否归档搜索结果")
                    console.log(resp)
                    this.tableData = resp.data.page.list
                    if (resp.data.page.totalCount > 0) {
                        this.gdForm.isGD = true
                    } else {
                        this.gdForm.isGD = false
                    }

                }.bind(this)).catch(function (err) {
                    console.error(err)
                });
            },
            /**
             * 加载卷内目录
             */
            loadJnml(nbxh) {
                let params = new URLSearchParams;
                params.append("nbxh", nbxh)
                console.info('加载卷内目录', nbxh)
                http.post('/dajnmlb/list', params).then(function (resp) {
                    if (resp.data.page.totalCount > 0) {
                        this.daJnmlData = resp.data.page.list
                        this.dangan.filePath = resp.data.page.list[0].ljmc
                        this.dangan.jnmlbh = resp.data.page.list[0].jnmlbh
                        this.$set(this.dangan, "hasJnml", true)
                        this.$set(this.dangan, "mlqx", resp.data.page.list[0].mlqx)
                        this.loadPdf(this.dangan.jnmlbh,2)
                    }else{
                        this.$set(this.dangan, "hasJnml", false)
                    }
                }.bind(this)).catch(function (err) {
                    console.error(err)
                })
            },
            /**
             * 保存文书档案
             */
            saveWsDangan() {
                let params = new URLSearchParams();
                params.append("bgqx", this.dangan.bgqx)
                params.append("nd", this.dangan.nd)
                params.append("wh", this.dangan.wh)
                params.append("bt", this.dangan.bt)
                params.append("rq", this.dangan.rq)
                params.append("qzh", this.dangan.qzh)
                params.append("nbxh", this.dangan.nbxh)
                params.append("js", this.dangan.js)
                params.append("zrr", this.dangan.zrr)
                http.post("/daws/update", JSON.stringify(this.dangan),
                    {
                        headers: {'Content-Type': 'application/json'}
                    }
                ).then(function (resp) {
                    console.log(resp)
                    if(resp.data.code==0){
                        this.$message.success("保存成功")
                    }
                }.bind(this)).catch(function (err) {
                    console.error(err)
                })
                //当重新上传过卷内目录文件后，更新卷内目录的文件
                if (this.upload.reUpLoadJnml) {
                    let jnmlFileParams = new URLSearchParams()
                    jnmlFileParams.append("uuid", this.upload.uuid)
                    if(this.dangan.hasJnml===true){
                        jnmlFileParams.append("jnmlbh", this.dangan.jnmlbh)
                    }else if(this.dangan.hasJnml===false){
                        jnmlFileParams.append("nbxh", this.dangan.nbxh)
                        jnmlFileParams.append("bt", this.dangan.bt)
                    }
                    http.post("/dajnmlb/updateJnmlFile", jnmlFileParams
                    ).then(function (resp) {
                        if(resp.data.code==0){
                            this.$message.success("卷内目录文件更新成功")
                            this.upload.reUpLoadJnml=false
                        }
                        console.log(resp)
                    }.bind(this)).catch(function (err) {
                        console.error(err)
                    })
                }
            },
            deleteWsFile(row,index){
                this.$confirm('是否删除该文档?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let params = new URLSearchParams()
                    params.append("nbxh",row.nbxh)
                    http.post('/daws/deleteByNbxh',params).then(function (resp) {
                        console.log(resp.data)
                        if (resp.data.code == 0) {
                            this.$message.success("删除成功")
                            this.tableData.splice(index,1)
                        } else {
                            this.$message.error("添加用户失败")
                        }
                    }.bind(this)).catch(function (err) {
                        console.error(err)
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },
            logout(){
                window.localStorage.clear()
                location.href="/dangan/logout"
            },
            isLogin(){
                window.localStorage
                var login= window.localStorage.getItem("login")
                console.log("登录状态："+login)
                if(login&&login=="true"){
                    console.log("已登录")
                    this.loginForm.loginVisible=false
                }else{
                    this.$message.error("还未登录")
                    this.loginForm.loginVisible=true
                    console.log("还未登录")
                }
            },
            login(formName){
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        console.log("登录表单验证通过")
                        var data = "?username="+this.loginForm.username+"&password="+this.loginForm.password+"&captcha="+this.loginForm.password
                        http({ method: 'post',
                            url: 'sys/login'+data,
                            headers: {'Content-Type': 'application/json'}
                        }).then(function (result) {
                            if(result.data.code == 0){//登录成功
                                window.localStorage.setItem("login","true")
                                this.loginForm.loginVisible=false
                            }else{
                                window.localStorage.setItem("login","false")
                                this.$message.error(result.data.msg)
                            }
                        }.bind(this)).catch(function (err) {
                            console.error(err)
                        })
                        // http.post('sys/login',params, {
                        //     headers: {'Content-Type': 'application/json'}
                        // })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },

            resetPassword(){
                this.$refs['pwdForm'].validate((valid) => {
                    if (valid) {
                        console.log("密码修改表单验证通过")
                        var data = "?password="+this.pwdForm.oldPassword+"&newPassword="+this.pwdForm.newPassword
                        http({ method: 'post',
                            url: 'sys/user/password'+data,
                            headers: {'Content-Type': 'application/json'}
                        }).then(function (result) {
                            if(result.data.code == 0){//修改密码成功
                                this.$message.success("密码修改成功")
                                this.pwdForm.resetPasswordVisible=false
                                this.pwdForm.oldPassword=''
                                this.pwdForm.newPassword=''
                            }else{
                                this.$message.error(result.data.msg)
                            }
                        }.bind(this)).catch(function (err) {
                            console.error(err)
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            }
        }
    })
</script>
</html>



